﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace BWindingMachine
{
    public partial class ProductionInfoForm : Form
    {
        double error_kaxian_num, error_chuxianwei_num, production;

        public ProductionInfoForm()
        {
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            textBox5.Text = Convert.ToString(Data.error_kaxian_num);

            textBox10.Text = Convert.ToString(Data.production);

            textBox7.Text = Convert.ToString(Data.production_OK);
            textBox9.Text = Convert.ToString(Data.cycle_time / 1000) + "秒" + Convert.ToString(Data.cycle_time % 1000 / 10);

            textBox11.Text = Convert.ToString(Data.run_time / 3600) + "时" + Convert.ToString(Data.run_time % 3600 / 60) + "分" + Convert.ToString(Data.run_time % 60) + "秒";
            textBox13.Text = Convert.ToString(Data.stop_time / 3600) + "时" + Convert.ToString(Data.stop_time % 3600 / 60) + "分" + Convert.ToString(Data.stop_time % 60) + "秒";
            textBox12.Text = Convert.ToString(Data.all_production_OK);


            error_kaxian_num = Convert.ToDouble(Data.error_kaxian_num);
            production = Convert.ToDouble(Data.production);




            if (production != 0)
            {

                textBox1.Text = Convert.ToString(error_kaxian_num * 100 / production) + " %";
                textBox8.Text = Convert.ToString(100 - error_kaxian_num * 100 / production) + " %";


            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult a = MessageBox.Show(" 是否清除数据？", "消息", MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
            if (a == DialogResult.Yes)
            {
                Data.Send("qingchu");
                System.Threading.Thread.Sleep(50);
                Data.Send("qingchu");
                System.Threading.Thread.Sleep(50);
                Data.Send("qingchu");
                System.Threading.Thread.Sleep(50);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}